import {defineStore} from 'pinia'
import {ref,computed} from 'vue'
//组合式API
const useUserStore=defineStore("useUserStore",()=>{
    //state数据
    let age=ref(18);
    let gender=ref("男");
    //getters计算属性
    let isOlder=computed(()=>{
        return age.value>=18?"成年":"未成年"
    });
    //actions函数
    let setAgeUp=(up)=>{
        age.value+=parseInt(up);//修改响应式数据
    }
    let setAgeDown=(down)=>{
        age.value-=parseInt(down);
    }
    return { age,isOlder,gender,setAgeUp,setAgeDown}
});
export default useUserStore;